﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace DAL
{
   public class BuyerFixedPricePeriod
    {
       /// <summary>
       /// 根据当前日期判断日期差
       /// </summary>
       /// <param name="times"></param>
       /// <returns></returns>
       public static int BuyerFixedPricePeriod_WithCountByDatetime(int comapanyid ,Nullable<DateTime> times)
       {
           return (int)DbHelper.ExecuteScalar("[dbo].[P_BuyerFixedPricePeriod_WithCountByDatetime]",comapanyid, times);
       }
       public static int insert(BuyerFixedPricePeriodEntity bfp)
       {
           return Convert.ToInt32(DbHelper.ExecuteScalar("[dbo].[p_BuyerFixedPricePeriod_insert]",bfp.Buyerid,bfp.StartTime,bfp.EndTime,bfp.CreateAdminid));
       }
       public static bool ifExistByBuyerIdAndTime(int buyerId,DateTime startTime,DateTime endTime)
       {
           if (Convert.ToInt32(DbHelper.ExecuteScalar("[dbo].[p_buyerFixedPricePeriod_ifExistByBuyerIdAndTime]",buyerId,startTime,endTime)) == 1)
               return true;
           else
               return false;
       }
       public static DataRow getLastperiodBybuyerid(int buyerId)
       {
           return DbHelper.ExecuteDataRow("[dbo].[p_buyerFixedPricePeriod_getLastperiodBybuyerid]", buyerId);
       }
       public static bool isValidReceiveDt(int orderId, DateTime newReceiveDt)
       {
           if (Convert.ToInt32(DbHelper.ExecuteScalar("[dbo].[p_BuyerFixedPricePeriod_isValidReceiveDt]", orderId, newReceiveDt)) == 1)
               return true;
           else
               return false;
       }
    }
}
